<template>
	<jn-page>
		<view class="wrap">
			<view class="u-tabs-box">
				 <u-tabs activeColor="#f29100" :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
			</view>
			<view class="">
				<view class="page-box" v-if="teamList != '' ">
					<view class="team" v-for="(item, index) in teamList" :key="item.id">
						<view class="team-box">
							<view class="team-hd">
								<view class="team-i">{{index + 1}}</view>
								<u-image :src="item.headimg" width="50" mode="widthFix" shape="circle"></u-image>
								<view class="team-name">{{ item.nickname }}</view>
							</view>
							<view class="team-ft">邀请时间 {{ item.create_at }}</view>
						</view>
					</view>
					<u-loadmore :status="loadStatus" bgColor="#f2f2f2"></u-loadmore>
				</view>
				<view class="page-box" v-if="teamList == '' ">
					<view>
						<view class="centre">
							<u-empty text="数据为空" mode="data"></u-empty>
						</view>
					</view>
				</view>
			</view>
		</view>
	</jn-page>
</template>

<script>
	export default {
		data() {
			return {
				teamList: [],
				list: [{
						name: '全部成员'
					},
					{
						name: '直属成员'
					},
					{
						name: '非直属成员'
					}
				],
				current: 0,
				loadStatus: 'loadmore',
				page: 1,
				total:0,
			}
		},
		onLoad(e) {
			this.current = e.current;
			this.getteam(this.current, this.page)
		},

		methods: {
			
			getteam(type, page) {  //all   child   grandson
				this.$u.post('/wxapi/api/getteam_list', {
					token: this.vuex_token.accessToken,
					'type': type,
					'page': page
					//serinfo:this.vuex_user.userinfo
				}).then(res => {
					console.log(res);
					if (res.code == 200) {
						this.page = res.data.allpage
						for(var child of res.data.datalist)
						{
							this.teamList.push(child);
						}
						//this.teamList = res.data.datalist
					} else if (res.code == 999) {

					}
					return false;
				});
			},

			onReachBottom() {
				if(this.total >= 12){
					this.loadStatus = 'loading';
					this.page = ++ this.page;
					setTimeout(() => {
						
						this.getorder(this.current, this.page);
						if(this.page >= 3) this.status = 'nomore';
						else this.status = 'loading';
					}, 500)
				}else{
					this.loadStatus = 'nomore';
				}
			},

			// tab栏切换
			change(index) {
				this.current = index;
				this.teamList=[];
				this.page= '1';
				this.getteam(index,this.page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.team {
		background: white;
		padding: 30rpx;
		margin: 30rpx;
		font-size: 28rpx;
		box-shadow: 14rpx 18rpx 68rpx rgba(0, 0, 0, 0.1);
		border-radius: 16rpx;

		.team-box {
			.team-hd {
				display: flex;
				flex-direction: row;
				align-items: center;

				.team-i {
					margin-right: 20rpx;
				}

				.team-name {
					margin-left: 20rpx;
				}
			}

			.team-ft {
				margin-top: 30rpx;
			}
		}
	}
	
	.centre {
		text-align: center;
		margin: 200rpx auto;
		font-size: 32rpx;
		image {
			width: 164rpx;
			height: 164rpx;
			border-radius: 50%;
			margin-bottom: 20rpx;
		}
		.tips {
			font-size: 24rpx;
			color: #999999;
			margin-top: 20rpx;
		}
		.btn {
			margin: 80rpx auto;
			width: 200rpx;
			border-radius: 32rpx;
			line-height: 64rpx;
			color: #ffffff;
			font-size: 26rpx;
			background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
		}
	}

	.wrap {
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
	}

	.swiper-box {
		flex: 1;
	}

	.swiper-item {
		height: 100%;
	}
</style>
